// components/Swiper/swiper.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array,
      value: [],
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    winHeight: "",//窗口高度
    currentTab: 0, //预设当前项的值
    scrollLeft: 0, //tab标题的滚动条位置
  },
  /**
   * 组件的方法列表
   */
  methods: {


    // 滚动切换标签样式
    switchTab: function (e) {
      this.setData({
        currentTab: e.detail.current
      });
      this.checkCor();
    },
    // 点击标题切换当前页时改变样式
    swichNav: function (e) {
      var cur = e.target.dataset.current;
      var classId = e.target.id
      this.jumpTable(cur, classId)

    },
   
    jumpTable(cur, classId) {
      if (this.data.currentTaB == cur) { }
      else {
        this.setData({
          currentTab: cur
        })
      }
      this.triggerEvent("jumpTable")
    },
    //判断当前滚动超过一屏时，设置tab标题滚动条。
    checkCor: function () {
      if (this.data.currentTab > 4) {
        this.setData({
          scrollLeft: 300
        })
      } else {
        this.setData({
          scrollLeft: 0
        })
      }
    },
    zhishiying: function () {
      var that = this;
      //  高度自适应
      wx.getSystemInfo({
        success: function (res) {
          var clientHeight = res.windowHeight,
            clientWidth = res.windowWidth,
            rpxR = 750 / clientWidth;
          var calc = clientHeight * rpxR - 180;
          console.log(calc)
          that.setData({
            winHeight: calc
          });
        }
      });
    },
  }
})
